package neuralNetwork.execution;

import java.util.Collection;

import networkTraining.DataSet;
import neuralModel.neuron.INeuron;
import neuralNetwork.INeuralNetwork;

public class NeuralNetworkExecutor
{
	private NeuralNetworkExecutor()
	{

	}

	public static void performTimeSteps(INeuralNetwork neuralNetwork, int stepCount)
	{
		for (int i = 0; i < stepCount; i++)
			performTimeStep(neuralNetwork);
	}

	public static void performTimeStep(INeuralNetwork neuralNetwork)
	{

		Collection<INeuron> neurons = neuralNetwork.getNeuronMap().values();
		for (INeuron neuron : neurons)
		{
			neuron.updateInducedLocalField();
			neuron.updateOutputValue();
		}

		for (INeuron neuron : neurons)
		{
			neuron.driveOutputValue();
		}

	}
	
	public static void ExecuteNetwork(INeuralNetwork neuralNetwork, DataSet dataSet)
	{
		for (String inputName : dataSet.getInputNames())
		{
			neuralNetwork.getNeuron(inputName).setOutputValue(dataSet.getInputValue(inputName));
		}

		performTimeSteps(neuralNetwork, neuralNetwork.getLayerCount());
	}

}
